package com.example.servlet.manager;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

@WebServlet("/manager_logout")
public class mLogoutServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.getSession().removeAttribute("manager");
        Cookie cookie_m_username = new Cookie("m_account", "");
        cookie_m_username.setMaxAge(0);
        Cookie cookie_m_password = new Cookie("m_password", "");
        cookie_m_password.setMaxAge(0);
        resp.addCookie(cookie_m_username);
        resp.addCookie(cookie_m_password);
        resp.sendRedirect("manager_login");
    }
}
